//	---------------------------------------------------------------------------
//	dark-matter-data
//	Copyright (c) 2014 dark-matter-data committers
//	---------------------------------------------------------------------------
//	This program is free software; you can redistribute it and/or modify it
//	under the terms of the GNU Lesser General Public License as published by the
//	Free Software Foundation; either version 3 of the License, or (at your
//	option) any later version.
//	This program is distributed in the hope that it will be useful, but WITHOUT
//	ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//	FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
//	more details.
//	You should have received a copy of the GNU Lesser General Public License along
//	with this program; if not, see <http://www.gnu.org/licenses/lgpl.html>.
//	---------------------------------------------------------------------------
package org.dmd.gpb.shared.generated.enums;

import java.util.*;

import org.dmd.dmc.DmcEnumIF;

/**
 * The FieldRuleEnum indicates whether a field is required, optional or
 * repeated.\n <p/>\n REQUIRED is Forever You should be very careful about
 * marking fields as required. If at some\n point you wish to stop writing or
 * sending a required field, it will be problematic to change\n the field to
 * an optional field ? old readers will consider messages without this field
 * to be\n incomplete and may reject or drop them unintentionally. You should
 * consider writing\n application-specific custom validation routines for
 * your buffers instead. Some engineers\n at Google have come to the
 * conclusion that using required does more harm than good; they\n prefer to
 * use only optional and repeated. However, this view is not universal.
 * <P>
 * Generated from the dmdgpb schema at version 0.1
 * <P>
 * This code was auto-generated by the dmogenerator utility and shouldn't be altered manually!
 * Generated from: org.dmd.dms.util.DmoEnumFormatter.dumpEnum(DmoEnumFormatter.java:100)
 */
public enum FieldRuleEnum implements DmcEnumIF
{
    REQUIRED(0,"A well-formed message must have exactly one of this field."),

    OPTIONAL(1,"A well-formed message can have zero or one of this field (but not more than one)."),

    REPEATED(2,"This field can be repeated any number of times (including zero) in a well-formed message. The order of the repeated values will be preserved.");

    // Maps our integer value to the enumeration value
    private static final Map<Integer,FieldRuleEnum> lookup = new HashMap<Integer,FieldRuleEnum>();

    static {
        for(FieldRuleEnum s : EnumSet.allOf(FieldRuleEnum.class))
            lookup.put(s.intValue(), s);
    }

    // Maps our enumeration (string) value to the enumeration value
    private static final Map<String,FieldRuleEnum> lookupString = new HashMap<String, FieldRuleEnum>();

    static {
        for(FieldRuleEnum s : EnumSet.allOf(FieldRuleEnum.class))
            lookupString.put(s.name(), s);
    }

    // Our current value as an int - normally, this isn't available in an enum
    private int ival;

    // Our current display value as a String
    private String dval;

    /**
     * This private constructor allows us to access our int value when required.
     */
    private FieldRuleEnum(int i, String d){
        ival = i;
        dval = d;
    }

    /**
     * Returns the value of this enum value as an int.
     */
    public int intValue(){
        return(ival);
    }

    /**
     * Returns the display value of this enum value as a String.
     */
    public String displayValue(){
        return(dval);
    }

    /**
     * Returns the enum value of the specified int or null if it's not valid.
     */
    public static FieldRuleEnum get(int code) {
        return(lookup.get(code));
    }

    /**
     * Returns a value for this enum or throws an exception if the String value isn't
     * a valid member of this enum.
     */
    public static FieldRuleEnum get(String str) {
        return(lookupString.get(str.toUpperCase()));
    }

}